function Out = strclip(S,D,F)
%
% STRCLIP clips a string into two part.
%    Out = STRCLIP(S,D,F), where S is the string which will be clipped
%    by D delimiter. The F is true or false. It depends on Out is the
%    last part of the string or the first part. Note that Out does not
%    contain the delimiter. If S doesn't contain D then Out = -1.
%
%    Author : Csaba Domokos (dcs@inf.u-szeged.hu)

idx = strfind(S,D);
if isempty(idx)
    Out = -1;
    return 
end
if numel(idx) == 0
    Out = S;
    return
end
idx = idx(1);
if F
    idx = min(idx + 1, numel(S));
    Out = S(idx : numel(S));
else
    idx = max(idx - 1, 1);
    Out = S(1 : idx);
end

return
end